ostree.git
9 years agoFix regression for symlinks in bare-user repos
Alexander Larsson [Fri, 21 Oct 2016 09:16:42 +0000 (11:16 +0200)]
Fix regression for symlinks in bare-user repos

Commit 1d4f1b8878addd28059c3a3928640491755cd615 started using hardlinks
checkouts of symlinks. However, symlinks are not stored as symlink in the
repo for bare-user repos, so this breaks user-mode checkouts of such repos.

We fix this by checking for !is_symlink in the bare-user case.

This fixes:
     https://github.com/ostreedev/ostree/issues/537

Closes: #538
Approved by: giuseppe

9 years ago.redhat-ci.yml: use projectatomic/ostree-tester
Jonathan Lebon [Wed, 19 Oct 2016 20:49:56 +0000 (16:49 -0400)]
.redhat-ci.yml: use projectatomic/ostree-tester

Same Dockerfile, but automated to rebuild on pushes.

Closes: #536
Approved by: giuseppe

9 years agoadd .redhat-ci.yml and .redhat-ci.Dockerfile
Jonathan Lebon [Wed, 19 Oct 2016 16:37:54 +0000 (12:37 -0400)]
add .redhat-ci.yml and .redhat-ci.Dockerfile

Add a YAML file for the new Red Hat CI framework.

Rather than re-installing all the build deps everytime, which takes
time, I added a Dockerfile that we can wire up to the Docker Hub. For
now it lives at `jlebon/ostree-tester:rhci`, but we can move it under
the `projectatomic` org (or a new `ostree` org).

Closes: #535
Approved by: cgwalters

9 years agocore: Do create hardlinks to symlinks for checkouts
Colin Walters [Tue, 4 Oct 2016 19:23:04 +0000 (15:23 -0400)]
core: Do create hardlinks to symlinks for checkouts

I was noticing a recent performance issue with checkouts
which seemed to be mostly us going back to doing a `fsync()` on
directories.

Regardless, while looking at that, I saw we were spending time
creating new symlinks. Even though symlinks are small, it's still
better to hardlink them.

Going way back in time, the reason we weren't doing this is
because we were hitting `EMFILE` on ext4, but that was for
gnome-continuous which creates *many* build roots.  Even
there though, they're just a cache, and we handle `EMFILE`.

For ostree-for-host-system, we don't expect to have many roots (just 3
at most transiently), so hardlinking symlinks does make sense.

Closes: #521
Approved by: jlebon

9 years agoOstreeFetcher: provide proxy credentials if needed
Jonathan Lebon [Fri, 14 Oct 2016 13:25:01 +0000 (09:25 -0400)]
OstreeFetcher: provide proxy credentials if needed

There seems to be an issue in libsoup which causes basic auth
credentials to not be passed to the proxy during requests. We thus have
to handle PROXY_UNAUTHORIZED responses and provide the auth ourselves.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1370558
Related: https://bugzilla.gnome.org/show_bug.cgi?id=772932

Closes: #529
Approved by: cgwalters

9 years agoostree-sysroot-deploy.c: delete redundant check
Jonathan Lebon [Thu, 13 Oct 2016 16:05:54 +0000 (12:05 -0400)]
ostree-sysroot-deploy.c: delete redundant check

Just noticed this while inspecting the code. The deployments retrieved
by `_ostree_sysroot_list_deployment_dirs_for_os` will forcibly already
have a matching osname since it indirectly uses that same variable to
construct them. Having a check there makes it look like there may be
subtle corner cases, when there aren't.

Closes: #529
Approved by: cgwalters

9 years agodocs: amend vmlinuz & initramfs naming convention
Jonathan Lebon [Thu, 13 Oct 2016 15:56:46 +0000 (11:56 -0400)]
docs: amend vmlinuz & initramfs naming convention

I was confused while reading the docs how this could work, since in at
least the Fedora/CentOS/RHEL distros, they're named e.g.
initramfs-`uname -r`-$checksum.

Closes: #529
Approved by: cgwalters

9 years agopull: Support multiple specifications of --subpath
Alexander Larsson [Wed, 5 Oct 2016 19:26:38 +0000 (21:26 +0200)]
pull: Support multiple specifications of --subpath

I need this in flatpak to avoid doing multiple pulls when doing
locale subsetting.

Closes: #523
Approved by: cgwalters

9 years agopull: Support inherit-transaction
Alexander Larsson [Fri, 7 Oct 2016 14:28:57 +0000 (16:28 +0200)]
pull: Support inherit-transaction

If this is true, don't initiate, abort of commit a transaction, instead
it is assumed that the caller initiated the transaction, and that it
will eventually be commited.

This allows you to do multiple pulls or a combination of pulls and
commits in a single transaction.

Closes: #525
Approved by: cgwalters

9 years agoRelease 2016.11
Colin Walters [Thu, 6 Oct 2016 16:56:18 +0000 (12:56 -0400)]
Release 2016.11

Closes: #524
Approved by: cgwalters

9 years agolibglnx: Update to latest
Colin Walters [Wed, 5 Oct 2016 14:13:33 +0000 (10:13 -0400)]
libglnx: Update to latest

This pulls in a new compilation flag for wrpseudo compatibility.  Also
note we need to add some includes since glnx-libcontainer went away,
and with it some includes for `sys/mount.h` etc.

Closes: #522
Approved by: cgwalters

9 years agotrivial-httpd: Port mostly to fd-relative
Colin Walters [Wed, 14 Sep 2016 20:08:24 +0000 (16:08 -0400)]
trivial-httpd: Port mostly to fd-relative

We were seeing some weird potential memory corruption in this code
when using it for `rpm-ostree-toolbox installer`, which is almost
certainly not its fault, but let's use it as an excuse to port
(mostly) to fd-relative and away from GFile.

Dropping the last GFile use here is a bit tricky as it does have a
nice high level wrapper around inotify.

Closes: #512
Approved by: jlebon

9 years agocheckout: Fix fsync defaults for new API to be off for real
Colin Walters [Tue, 4 Oct 2016 19:39:15 +0000 (15:39 -0400)]
checkout: Fix fsync defaults for new API to be off for real

My previous change in https://github.com/ostreedev/ostree/pull/425
actually broke things so we basically used the repository defaults =(

This is a subtle mess since we're only trying to flip things off
for the *new* API.

Clean this up so that the "default repo inheritance" lives only in one
place - in the compat layer for the old checkout API.  The new
checkout API defaults to off period, so the repository state is
irrelevant.

Closes: #520
Approved by: jlebon

9 years agoFix spelling of "repository"
Simon McVittie [Sat, 1 Oct 2016 15:07:08 +0000 (16:07 +0100)]
Fix spelling of "repository"

Detected by Debian's Lintian tool.

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #519
Approved by: cgwalters

9 years agoadmin: Allow running status unlocked
Dan Nicholson [Thu, 22 Sep 2016 16:13:39 +0000 (09:13 -0700)]
admin: Allow running status unlocked

It's useful to let non-root see the current system status.

Closes: #515
Closes: #516
Approved by: jlebon

9 years agodocs: add mention of rpm-ostree package layering
Jonathan Lebon [Tue, 20 Sep 2016 16:04:41 +0000 (12:04 -0400)]
docs: add mention of rpm-ostree package layering

Closes: #514
Approved by: cgwalters

9 years agoostree_sysroot_init_osname: also create /var/log
Jonathan Lebon [Tue, 20 Sep 2016 15:45:57 +0000 (11:45 -0400)]
ostree_sysroot_init_osname: also create /var/log

/var/log is another one of those core directories that should be made
available and properly labeled during early boot before tmpfiles.d
starts up.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1265295

Closes: #513
Approved by: cgwalters

9 years agoboot: Ensure we remount /var writable before systemd does journal flush
Colin Walters [Wed, 14 Sep 2016 16:56:07 +0000 (12:56 -0400)]
boot: Ensure we remount /var writable before systemd does journal flush

Otherwise, we may not get a persistent journal for the first boot.
https://bugzilla.redhat.com/show_bug.cgi?id=1265295

Closes: #511
Approved by: jlebon

9 years agosysroot: Drop an unnecessary fsync
Colin Walters [Wed, 14 Sep 2016 00:38:21 +0000 (20:38 -0400)]
sysroot: Drop an unnecessary fsync

While looking at a slow update issue (which I'm guessing is
unpredictable I/O latency in an OpenStack instance), I noticed
in one of the traces we were inside a fsync here.

Dropping the fsync here is just another of a long series of unwinding
them - we `syncfs()` the sysroot fd and `/boot` and we have a big
`sync()` anyways.

Closes: #508
Approved by: jlebon

9 years agosysroot: Drop an fsync for origin file when writing deployments
Colin Walters [Wed, 14 Sep 2016 01:09:48 +0000 (21:09 -0400)]
sysroot: Drop an fsync for origin file when writing deployments

More fsync pruning.  Since we have a public API for writing the origin
file and it did a fsync before, let's preserve that.  But when writing
deployments as part of a full transaction, we rely on the global
`syncfs()`, so add an internal function for origin file writing that
doesn't.

Closes: #509
Approved by: giuseppe

9 years agosysroot: Port origin writing code to fd-relative
Colin Walters [Wed, 14 Sep 2016 01:05:08 +0000 (21:05 -0400)]
sysroot: Port origin writing code to fd-relative

Just preparatory cleanup for a next patch which makes
the fsyncing configurable.

Closes: #509
Approved by: giuseppe

9 years agosysroot: Port some small cleanup code to fd-relative
Colin Walters [Wed, 14 Sep 2016 01:26:38 +0000 (21:26 -0400)]
sysroot: Port some small cleanup code to fd-relative

Just a quick patch since I saw this function scroll by in Emacs and it
was too ugly not to be rewritten.

Closes: #510
Approved by: giuseppe

9 years agoostree_sysroot.c: Don't close sysroot_fd twice.
Owen W. Taylor [Tue, 13 Sep 2016 13:05:52 +0000 (09:05 -0400)]
ostree_sysroot.c: Don't close sysroot_fd twice.

If ostree_sysroot_unload() was called explicitly, then sysroot_fd
would be closed again at finalization time, possibly closing a
random file descriptor belonging to some other part of the
application.

Closes: #507
Approved by: cgwalters

9 years agoostree-repo.c: Fix file descriptor cleanup
Owen W. Taylor [Tue, 13 Sep 2016 13:03:53 +0000 (09:03 -0400)]
ostree-repo.c: Fix file descriptor cleanup

0 was used as an "unset" flag for tmp_dir_fd, which is technically
incorrect. For cache_dir_fd, -1 was used as the sentinal but 0
was checked for, resulting in close(-1).

Closes: #507
Approved by: cgwalters

9 years agopull: Do allow executing deltas when mirroring into bare{,-user}
Colin Walters [Mon, 12 Sep 2016 00:33:42 +0000 (20:33 -0400)]
pull: Do allow executing deltas when mirroring into bare{,-user}

In https://github.com/ostreedev/ostree/pull/408 we fixed a
bug where we would crash when trying to execute deltas into
an archive repo (which isn't presently supported).

But that was overly aggressive - we obviously *can* execute deltas
when mirroring into a bare repo.  This should fix a regression with
the way flatpak uses mirroring to pull from a user repo into the
system.

Closes: #506
Approved by: alexlarsson

9 years agostatic-delta: add some error handling
Jonathan Lebon [Fri, 9 Sep 2016 18:52:18 +0000 (14:52 -0400)]
static-delta: add some error handling

We make _ostree_parse_delta_name() a bit more defensive since it handles
user input.

Closes: #504
Closes: #505
Approved by: cgwalters

9 years agoRelease 2016.10
Colin Walters [Thu, 8 Sep 2016 20:54:00 +0000 (16:54 -0400)]
Release 2016.10

Closes: #502
Approved by: cgwalters

9 years agocore: Make OSTREE_TIMESTAMP public API
Colin Walters [Thu, 8 Sep 2016 20:50:35 +0000 (16:50 -0400)]
core: Make OSTREE_TIMESTAMP public API

This way e.g. flatpak can detect which timestamp it should use.
See `flatpak/common/flatpak-utils.c:flatpak_zero_mtime`.

Closes: #501
Approved by: cgwalters

9 years agosysroot: Avoid double cleanup, and ensure no cleanup if specified
Colin Walters [Thu, 8 Sep 2016 17:38:08 +0000 (13:38 -0400)]
sysroot: Avoid double cleanup, and ensure no cleanup if specified

Since forever, we've been doing two cleanups.  In
https://github.com/ostreedev/ostree/commit/8ece4d6d51bdbe3e41ab318259276bb83e553aa0
I thought we were doing just one and wanted to go to zero (if specified),
but I actually just dropped one cleanup.

In https://github.com/projectatomic/rpm-ostree/pull/452
@jlebon pointed out the duplication.  Fix this by creating a new internal
deploy wrapper that takes cleanup flags.

(Since we already had the "piecemeal cleanup" API internally, let's
 frame it in terms of that, rather than passing down a boolean).

Closes: #500
Approved by: jlebon

9 years agofetcher: Fix another finalization deadlock
Colin Walters [Thu, 8 Sep 2016 16:39:42 +0000 (12:39 -0400)]
fetcher: Fix another finalization deadlock

If the current repo is already up to date (we have no content to
fetch), it's possible for the fetcher to not request any URIs.  So
create and then finalize it quickly.

Finalization involves calling `g_main_loop_quit()` +
`g_thread_wait()`.  However, if `g_main_loop_quit()` is run *before*
`g_main_loop_run()`, we'll deadlock because GMainLoop assumes in
`_run()` to start things.

This is a common trap - ideally, GMainLoop would record if `_quit()`
was called before `_run()` or something, but doing that now would
likely break people who are expecting quit() -> run() to restart.

In general, we've moved in various GLib-consuming apps to an
explicit "main context iteration with termination condition" model;
see `pull_termination_condition()` in the pull code.

This fixes this race condition.

I verified that an assertion in `_finalize` that more than
zero URIs were requested was hit in multiple test cases, and this patch
has survived a while of make check loops.

Closes: https://github.com/ostreedev/ostree/issues/496
Closes: #499
Approved by: jlebon

9 years agodelta: Unreference files we've processed
Colin Walters [Thu, 8 Sep 2016 14:47:33 +0000 (10:47 -0400)]
delta: Unreference files we've processed

This should help avoid address space exhaustion on 32 bit systems,
and in general is obviously going to improve efficiency.

Closes: #498
Approved by: alexlarsson

9 years agorepo: Only use mmap() for metadata > 16k
Colin Walters [Thu, 1 Sep 2016 20:09:30 +0000 (16:09 -0400)]
repo: Only use mmap() for metadata > 16k

See http://stackoverflow.com/questions/258091/when-should-i-use-mmap-for-file-access
and
https://lwn.net/Articles/591978/

I didn't really notice much performance difference in some small
tests, but I happened to be stracing and realized we were `mmap()`ing
even for 50 bytes which is not very useful, so let's not do it.

Closes: #489
Approved by: alexlarsson

9 years agodelta: Add missing `goto out` for failure to mmap()
Colin Walters [Thu, 8 Sep 2016 14:29:10 +0000 (10:29 -0400)]
delta: Add missing `goto out` for failure to mmap()

This was hit in practice when generating a delta for a flatpak app on ARM
it looks like.

Closes: #497
Approved by: alexlarsson

9 years agorepo: Revert default timestamp from 1 back to 0
Colin Walters [Thu, 8 Sep 2016 11:11:52 +0000 (07:11 -0400)]
repo: Revert default timestamp from 1 back to 0

Quoting Dan Nicholson in

  <https://github.com/ostreedev/ostree/pull/330#issuecomment-245499099>

  mtime of 0 has been the semantics of ostree deployments from basically
  the beginning of the project. We (and others, see
  flatpak/flatpak@b5204c9) rely on that fact when generating trees.

  In particular, this affects caches that use the mtime of the
  associated file or directory to determine if the cache is valid. By
  arbitrarily changing the mtime of the files to something else, all
  the caches we setup in the build are now invalidated. Preseeding
  caches is really important to the user experience as it avoids
  having the user wait while they're regenerated on first run.

  Now, we could change our build infrastructure to preset all the
  mtimes to 1 to match this change, but what does that do for our
  existing users who are on an ostree that deploys with mtimes of 0?
  We could just revert this change at Endless (and the associated one
  in Flatpak), and that would be fine for our users. However, if we
  point non-Endless users to our apps, they'll have the great
  experience of waiting 10 seconds the first time they launch it while
  the fontconfig cache is rebuilt unnecessarily.

Closes: #495
Approved by: jlebon

9 years agogpg: do not segfault when the algorithm name is not known
Giuseppe Scrivano [Wed, 7 Sep 2016 10:15:26 +0000 (12:15 +0200)]
gpg: do not segfault when the algorithm name is not known

Reported by: Patrick Uiterwijk
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #494
Approved by: cgwalters

9 years agoostree-prepare-root: Fix running with musl
William Manley [Wed, 31 Aug 2016 16:15:48 +0000 (17:15 +0100)]
ostree-prepare-root: Fix running with musl

musl libc's implementation of `realpath` works by opening the path and then
doing a lookup in `/proc/self/fd` to find the canonical path.  This fails
if `/proc` is not mounted.  This causes problems for us if
`ostree-prepare-root` is `init` as `/proc` won't be mounted.

We have to mount `/proc` anyway for `/proc/cmdline` so this fix just
expands the scope over which `/proc` is mounted to include both our
`realpath` calls.

See also:

* http://www.openwall.com/lists/musl/2016/06/08/2 and
* http://git.musl-libc.org/cgit/musl/tree/src/misc/realpath.c?id=e738b8cbe64b6dd3ed9f47b6d4cd7eb2c422b38d

Closes: #485
Approved by: cgwalters

9 years agoostree-prepare-root: Error if realpath fails
William Manley [Wed, 31 Aug 2016 16:07:17 +0000 (17:07 +0100)]
ostree-prepare-root: Error if realpath fails

I've seen it fail with musl which needs `/proc` to be mounted for it to
work.  The error messages we're rather confusing before.  At least this
now points to the right location.

Closes: #485
Approved by: cgwalters

9 years agoswitchroot: Fix test-switchroot now autotools can build static
William Manley [Wed, 31 Aug 2016 17:14:19 +0000 (18:14 +0100)]
switchroot: Fix test-switchroot now autotools can build static

This test previously depended on manually building ostree-prepare-root.
Since 42dab85 we've been able to build static binaries with the usual
autotools build-system.  This change reflects the fact that
`ostree-prepare-root` is built into $srcdir rather than `src/switchroot`
where I was building manually.

This test now passes with `./configure --with-static-compiler=gcc` (glibc)
but still fails with `./configure --with-static-compiler=musl-gcc` (musl).

Closes: #485
Approved by: cgwalters

9 years agoswitchroot: Fix build on Ubuntu
William Manley [Wed, 31 Aug 2016 16:25:22 +0000 (17:25 +0100)]
switchroot: Fix build on Ubuntu

Was failing with error:

    src/switchroot/ostree-prepare-root.c:30:20: fatal error: config.h: No such file or directory
    compilation terminated.

Reported by and fix provided by @gatispaeglis.

Closes: #485
Approved by: cgwalters

9 years agobuild: Actually distribute man page XML source
Dan Nicholson [Thu, 1 Sep 2016 18:29:26 +0000 (11:29 -0700)]
build: Actually distribute man page XML source

The make substitution pattern was wrong. The source files are
"ostree.xml", not "ostree.1.xml", for instance.

Closes: #488
Approved by: cgwalters

9 years agobuild: Distribute man page XML source
Dan Nicholson [Thu, 1 Sep 2016 18:29:26 +0000 (11:29 -0700)]
build: Distribute man page XML source

Without this, the manual pages can't actually be regenerated from a dist
tarball, and running make clean will remove all traces of them.

Closes: #486
Approved by: cgwalters

9 years agobuild: Set --enable-man during distcheck
Dan Nicholson [Thu, 1 Sep 2016 18:26:48 +0000 (11:26 -0700)]
build: Set --enable-man during distcheck

If xsltproc is not installed, then ENABLE_MAN will be false and the
generated man pages won't be distributed. Pass --enable-man to enforce
that the man pages will be generated and distributed.

Closes: #486
Approved by: cgwalters

9 years agopull code: clean up mirrorlist hack
Jonathan Lebon [Wed, 31 Aug 2016 17:16:36 +0000 (13:16 -0400)]
pull code: clean up mirrorlist hack

While converting the mirrorlist code from using GSList to GPtrArray, I
completely missed the fact that there is now a much cleaner way to do
this.

Closes: #484
Approved by: cgwalters

9 years agotests: add tests for contenturl and mirrorlist
Jonathan Lebon [Thu, 25 Aug 2016 19:34:34 +0000 (15:34 -0400)]
tests: add tests for contenturl and mirrorlist

Closes: #469
Approved by: cgwalters

9 years agolibtest: add has_gpgme() helper function
Jonathan Lebon [Thu, 25 Aug 2016 16:14:21 +0000 (12:14 -0400)]
libtest: add has_gpgme() helper function

Closes: #469
Approved by: cgwalters

9 years agopull: add mirrorlist support
Jonathan Lebon [Tue, 23 Aug 2016 19:55:15 +0000 (15:55 -0400)]
pull: add mirrorlist support

This commit adds mirrorlist support to the fetcher. Users can now
prepend url or/and contenturl by mirrorlist= to interpret the link as a
mirrorlist.

If an object is not found, the fetcher will automatically try the next
mirror in the order given in the list (assuming the order returned by
the server is significant).

Closes: #469
Approved by: cgwalters

9 years agopull: drop fetching_sync_uri
Jonathan Lebon [Mon, 22 Aug 2016 20:14:52 +0000 (16:14 -0400)]
pull: drop fetching_sync_uri

This made sense back when we used a main loop even when we needed to
fetch objects synchronously. Nowadays, we no longer actually update
progress before the FETCHING_OBJECTS phase, which is only for async
requests.

This allows us to get rid of fetch_uri_contents_membuf_sync() and to
generalize fetch_uri_contents_utf8_sync() so that it only requires a
fetcher. This will be needed later.

Closes: #469
Approved by: cgwalters

9 years agotrivial-httpd: prepend timestamp in log file
Jonathan Lebon [Thu, 18 Aug 2016 16:10:20 +0000 (12:10 -0400)]
trivial-httpd: prepend timestamp in log file

I've found this useful when monitoring multiple logs at the same time to
test the upcoming content & meta URL splitting.

Closes: #469
Approved by: cgwalters

9 years agopull code: support contenturl setting
Jonathan Lebon [Thu, 11 Aug 2016 20:01:27 +0000 (16:01 -0400)]
pull code: support contenturl setting

Allow users to pass a --contenturl during `remote add` and store it in
the remote config.

Fish out the contenturl setting from the remote config and use it when
downloading static deltas and objects (except for commit signatures).
The idea here is that items in the trust chain (summary & sigs) can be
fetched from a more secure e.g. TLS-pinned location, while objects
themselves are fetched from another location. Once mirrorlist support is
added, this use-case will become even more advantageous.

Closes: #469
Approved by: cgwalters

9 years agoRelease 2016.9
Colin Walters [Wed, 31 Aug 2016 14:40:18 +0000 (10:40 -0400)]
Release 2016.9

Closes: #481
Approved by: jlebon

9 years agorepo-pull: properly store the cancellable
Georges Basile Stavracas Neto [Wed, 31 Aug 2016 15:02:01 +0000 (12:02 -0300)]
repo-pull: properly store the cancellable

OSTree function ostree_repo_pull_with_options starts a
series of operations that makes heavy use of the PullData's
cancellable.

This isn't effective, however, since nowhere in the code
the OtPullData.cancellable field is set. This is visible,
for example, when trying to cancel a Flatpak pull and nothing
happens, because the cancellable is not properly passed
to the pull data.

Fix that by setting the cancellable field of the pull data. It
owns a reference for safety reasons, and unreferences it at the
end of the operation.

ostreedev/ostree#482

Closes: #483
Approved by: cgwalters

9 years agoswitchroot: Move `path_is_on_readonly_fs` to header file
William Manley [Tue, 30 Aug 2016 21:49:15 +0000 (22:49 +0100)]
switchroot: Move `path_is_on_readonly_fs` to header file

This simplifies the build system by removing the need for
`libswitchroot-mountutil.la`.

Original idea by @cgwalters in #477.

Closes: #478
Approved by: cgwalters

9 years agoswitchroot: Replace custom error printing with err/warn functions from libc
William Manley [Tue, 30 Aug 2016 21:36:20 +0000 (22:36 +0100)]
switchroot: Replace custom error printing with err/warn functions from libc

The `warn()` libc extension has exactly the same behaviour as our own
`perrorv` function, but is available in (at least) glibc and musl.  As an
added bonus the similar function `err()` which will exit with an error
code afterwards.

This implementation is tidier and allows us to get rid of our own
`perrorv`.  It paves the way to removing `ostree-mount-util.c` to simplify
the build scripts.

Original idea by @cgwalters in #477.

Closes: #478
Approved by: cgwalters

9 years agoostree-prepare-root: Allow building statically with musl
William Manley [Tue, 30 Aug 2016 19:28:02 +0000 (20:28 +0100)]
ostree-prepare-root: Allow building statically with musl

If the `--with-static-compiler=musl-gcc` configure flag is given.

ostree-prepare-root can be used as init in a system without a populated
/lib.  To support this use case we need to link statically as we will be
unable to locate libc.so at run time if it's not installed in /lib.

We support building ostree-prepare-root with a different compiler to the
rest of ostree so we can use musl rather than glibc.  This reduces the size
of the executable significantly: from ~700K -> ~30K.  We have to use
`_SCRIPTS` here to get autotools to install this as an executable but
without generating rules to make it itself which we have specified
manually.

See https://lists.gnu.org/archive/html/help-gnu-utils/2007-01/msg00007.html
for advice on using autotools in this manner.

Closes: #477
Approved by: cgwalters

9 years agoswitchroot: Fix building with musl libc
William Manley [Tue, 26 Jul 2016 16:42:17 +0000 (17:42 +0100)]
switchroot: Fix building with musl libc

POSIX and GNU define conflicting versions of `strerror_r`.  The GNU
version returns the string but doesn't necessilary write into buf.
The POSIX version writes into buf and returns the length but doesn't
necessilary append a terminate the string with a NUL if it's too long
to fit in buf.

This commit fixes building ostree-prepare-root with musl libc.  The
stripped static build with musl on my machine is 30K vs. 724K with glibc
static and 11K with glibc shared.

Closes: #477
Approved by: cgwalters

9 years agocommit: Don't delete tmp/cache dir
Colin Walters [Mon, 29 Aug 2016 15:03:35 +0000 (11:03 -0400)]
commit: Don't delete tmp/cache dir

We hold a fd open on this, and it's basically now expected
to be immortal.  Confer that status.

This was showing up in flatpak crashers, because we'd get
an unexpected errno.

(I didn't test this fixes the crasher, but it's clearly right)

https://bugzilla.redhat.com/show_bug.cgi?id=1347293

Closes: #476
Approved by: alexlarsson

9 years agosysroot: Add a flag to suppress post-deploy cleanup
Colin Walters [Mon, 29 Aug 2016 02:22:59 +0000 (22:22 -0400)]
sysroot: Add a flag to suppress post-deploy cleanup

I noticed seeing the output of `prune` twice in rpm-ostree, and had
always wondered why.  When reading the rpm-ostree code to fix
something else, reasons, I noticed the reason - we were pruning once
here, and then once after rpm-ostree regenerates its "base" refs.

There's no reason to clean twice, so let's add a flag so rpm-ostree
can suppress doing it inside libostree.

Closes: #474
Approved by: giuseppe

9 years agosysroot: Drop unnecessary `dup()` invocation
Colin Walters [Sat, 27 Aug 2016 12:50:47 +0000 (08:50 -0400)]
sysroot: Drop unnecessary `dup()` invocation

It's close-on-exec, not close-on-fork.  I was clearly confused when
writing this; it works just fine to reference the fd in the child and
`fchdir()` before exec.  So drop the unnecessary duplication.

Just noticed this while reading the code for a random other reason.

Closes: #473
Approved by: giuseppe

9 years agou-boot: Merge ostree's and systems uEnv.txt
Gatis Paeglis [Tue, 23 Aug 2016 12:32:35 +0000 (14:32 +0200)]
u-boot: Merge ostree's and systems uEnv.txt

This is a proper fix for:
https://bugzilla.gnome.org/show_bug.cgi?id=755787

With this patch, an admin (system builder) can now:

1) Edit /usr/lib/ostree-boot/uEnv.txt
2) Deploy the new tree. OSTree will append system's uEnv.txt
   to the OSTree's managed uEnv.txt (loader/uEnv.txt).

It is common for u-boot systems to read in an extra env
from external /uEnv.txt. The same file OSTree uses to pass
in its env. With this patch /uEnv.txt now contains OSTree's
env + custom env added by system builders.

Closes: #466
Approved by: cgwalters

9 years agopull: use same name for parameter and documentation comment
Giuseppe Scrivano [Fri, 26 Aug 2016 15:35:17 +0000 (17:35 +0200)]
pull: use same name for parameter and documentation comment

Fixes this warning:

src/libostree/ostree-repo-pull.c:2162: Warning: OSTree: ostree_repo_pull_with_options: unknown parameter 'remote_name_or_baseurl' in documentation comment, should be 'remote_name'

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #472
Approved by: jlebon

9 years agolib: Add an API to list only "our" objects, fix prune to use it
Colin Walters [Thu, 25 Aug 2016 15:53:27 +0000 (11:53 -0400)]
lib: Add an API to list only "our" objects, fix prune to use it

When doing a prune, we should not try to delete objects in parent
repos, since it'll fail.  There is a bigger discussion about the
semantics of `parent=` to be had, but this will fix trying to use
`ostree prune --repo=/ostree/repo/extensions/rpmostree/pkgcache`.

Closes: https://github.com/ostreedev/ostree/issues/467
Closes: #471
Approved by: jlebon

9 years agorepo: Add prefixes to errors for querying size/deleting
Colin Walters [Thu, 25 Aug 2016 17:16:46 +0000 (13:16 -0400)]
repo: Add prefixes to errors for querying size/deleting

I hit these while causing errors in prune.  Let's add the specific
object we were looking for.

Closes: #471
Approved by: jlebon

9 years agopull: Make .commitpartial files world readable
Colin Walters [Thu, 25 Aug 2016 00:18:09 +0000 (20:18 -0400)]
pull: Make .commitpartial files world readable

In CentOS, these happened to appear in a repo that is served
via rsync, and having them not be world-readable caused mirroring
tools to fail.

They aren't secret, so don't make them so.

Closes: #468
Approved by: giuseppe

9 years agopull_with_options: fix stray return FALSE
Jonathan Lebon [Thu, 18 Aug 2016 14:37:11 +0000 (10:37 -0400)]
pull_with_options: fix stray return FALSE

Closes: #465
Approved by: cgwalters

9 years agopull_with_options: allow GPG verification override
Jonathan Lebon [Thu, 18 Aug 2016 14:35:31 +0000 (10:35 -0400)]
pull_with_options: allow GPG verification override

We used to only look at the "gpg-verify" and "gpg-verify-summary"
options when we're passed a local URL. Make these options also have an
effect in the configured remote case.

Closes: #465
Approved by: cgwalters

9 years agopull_with_options: fix remote parameter name & desc
Jonathan Lebon [Thu, 18 Aug 2016 14:34:50 +0000 (10:34 -0400)]
pull_with_options: fix remote parameter name & desc

Closes: #465
Approved by: cgwalters

9 years agorofiles-fuse: Rework to be based on nlink
Colin Walters [Tue, 16 Aug 2016 13:26:16 +0000 (09:26 -0400)]
rofiles-fuse: Rework to be based on nlink

Programs like `useradd` try to `open(/etc/passwd, O_RDWR)` to append,
which didn't work with rofiles-fuse.  Thinking about this, I realized
that there's a simpler algorithm for "can we write to this file" which
is "does it have a hardlink count <= 1"?

Switching to this both drops complexity (we no longer need to keep a
hash table of files we created), and also lets useradd work.

Closes: #462
Approved by: jlebon

9 years agotest-rofiles-fuse: Actually check out via hardlinks
Colin Walters [Tue, 16 Aug 2016 17:07:51 +0000 (13:07 -0400)]
test-rofiles-fuse: Actually check out via hardlinks

The test suite was actually doing something before, just
not quite what I intended.  Without `-U` for bare-user checkouts
we end up doing a copy.

Now, a future commit will change how rofiles work, which would cause
the test suite to permit inplace mutation for non-hardlinked files.
So let's ensure they *are* hardlinked.

Closes: #462
Approved by: jlebon

9 years agofixup! fix typo in docs/manual/atomic-upgrades.md
Colin Walters [Fri, 12 Aug 2016 21:15:59 +0000 (17:15 -0400)]
fixup! fix typo in docs/manual/atomic-upgrades.md

Closes: #461
Approved by: giuseppe

9 years agoprune: Elaborate on what formats are accepted by dates
Colin Walters [Fri, 12 Aug 2016 21:10:54 +0000 (17:10 -0400)]
prune: Elaborate on what formats are accepted by dates

Inquiring minds want to know.

Closes: #461
Approved by: giuseppe

9 years agofix typo in docs/manual/atomic-upgrades.md
Adam Miller [Fri, 12 Aug 2016 19:37:18 +0000 (14:37 -0500)]
fix typo in docs/manual/atomic-upgrades.md

Signed-off-by: Adam Miller <maxamillion@fedoraproject.org>
Closes: #460
Approved by: cgwalters

9 years agorepo: Really ignore progress changed user data
Dan Nicholson [Thu, 11 Aug 2016 19:39:19 +0000 (12:39 -0700)]
repo: Really ignore progress changed user data

The documentation says this is ignored, implying that you should pass
NULL to it. However, the function immediately returns in this case even
though the argument isn't used anywhere.

Closes: #458
Approved by: cgwalters

9 years agomanual/repo.md: reword bits about the summary file
Jonathan Lebon [Wed, 10 Aug 2016 19:11:14 +0000 (15:11 -0400)]
manual/repo.md: reword bits about the summary file

Closes: #459
Approved by: cgwalters

9 years agoostree_bootdir: properly preprend $(prefix)
Jonathan Lebon [Thu, 11 Aug 2016 15:46:44 +0000 (11:46 -0400)]
ostree_bootdir: properly preprend $(prefix)

Closes: #457
Approved by: cgwalters

9 years agoostree_bootdir: prepend $(prefix) to path
Jonathan Lebon [Thu, 11 Aug 2016 14:29:56 +0000 (10:29 -0400)]
ostree_bootdir: prepend $(prefix) to path

Otherwise we break local installs.

Closes: #456
Approved by: cgwalters

9 years agoMove ostree-* executables to /usr/lib/ostree
Gatis Paeglis [Tue, 9 Aug 2016 13:23:04 +0000 (15:23 +0200)]
Move ostree-* executables to /usr/lib/ostree

Why not to use libexecdir?

Because this directory does not exist on some distros or paths
between distros varies. There are several reasons why a well
known path is prefered, for example when generating a kernel
command line:

init=${ostree}/usr/lib/ostree-boot/ostree-prepare-root

In addition this saves us some typing in a console when wanting
to access the "ostree" cmd line.

Closes: #449
Approved by: cgwalters

9 years agotests: Test that local pulls do not use deltas
Dan Nicholson [Tue, 9 Aug 2016 22:41:36 +0000 (15:41 -0700)]
tests: Test that local pulls do not use deltas

Pulls from local repos now default to disabling static deltas so that
objects are copied. To check this is the case, see if the object files
are hardlinked after pulling.

Closes: #447
Closes: #448
Approved by: cgwalters

9 years agopull: Disable static deltas by default for local pulls
Dan Nicholson [Fri, 5 Aug 2016 13:52:55 +0000 (06:52 -0700)]
pull: Disable static deltas by default for local pulls

For local pulls there's no benefit pulling the static delta over the
individual object files since there's no HTTP overhead. Furthermore,
processing deltas always generates the objects whereas a standard pull
ensures that the exact object files are copied. Using deltas also
prevents hardlinking the objects if the repos exist on the same
filesystem.

Closes: #447
Closes: #448
Approved by: cgwalters

9 years agotests: Ensure deltas for pulling when needed
Dan Nicholson [Tue, 9 Aug 2016 22:39:41 +0000 (15:39 -0700)]
tests: Ensure deltas for pulling when needed

When testing pulling of deltas, use the new --require-static-deltas
option to pull-local to ensure that deltas are actually used. To support
the require-static-deltas mode, the summary in the remote repo must be
generated.

Closes: #447
Closes: #448
Approved by: cgwalters

9 years agopull-local: Support requiring static deltas
Dan Nicholson [Tue, 9 Aug 2016 16:41:48 +0000 (09:41 -0700)]
pull-local: Support requiring static deltas

Add the --require-static-deltas option like pull to ensure static deltas
are processed for local pulls.

Closes: #447
Closes: #448
Approved by: cgwalters

9 years agodeltas: Use F_DUPFD_CLOEXEC properly
Dan Nicholson [Tue, 9 Aug 2016 18:46:30 +0000 (11:46 -0700)]
deltas: Use F_DUPFD_CLOEXEC properly

You need to supply an argument to F_DUPFD_CLOEXEC or fcntl will return
EINVAL. Use 3 as the minimum fd number as is standard.

Closes: #454
Closes: #448
Approved by: cgwalters

9 years agodeltas: Handle cleanup of fd array properly
Dan Nicholson [Tue, 9 Aug 2016 18:45:25 +0000 (11:45 -0700)]
deltas: Handle cleanup of fd array properly

If there's an early error, part_temp_fds will be NULL and dereferencing
the len member will segfault.

Closes: #454
Closes: #448
Approved by: cgwalters

9 years agolibostree.sym: Add 2016.9 section
Colin Walters [Tue, 9 Aug 2016 19:36:37 +0000 (15:36 -0400)]
libostree.sym: Add 2016.9 section

We should remember to do this in the commit updating configure.ac.

Closes: #453
Approved by: jlebon

9 years agoRelease 2016.8
Colin Walters [Tue, 9 Aug 2016 17:58:02 +0000 (13:58 -0400)]
Release 2016.8

It's time for a new release, there's enough queued and it's
been ~a month.

Closes: #452
Approved by: jlebon

9 years agotests: Port sysroot.js away from libgsystem
Colin Walters [Tue, 9 Aug 2016 17:52:43 +0000 (13:52 -0400)]
tests: Port sysroot.js away from libgsystem

My case-sensitive `git grep` didn't find this one originally,
but the Travis+Debian setup was configured to run it.

Closes: #451
Approved by: jlebon

9 years agotravis: Disable email notifications
Colin Walters [Tue, 9 Aug 2016 16:51:30 +0000 (12:51 -0400)]
travis: Disable email notifications

I'm getting spammed.  We'll see the results in the status.

Closes: #450
Approved by: jlebon

9 years agoFinal excision of libgsystem dependency
Colin Walters [Thu, 23 Jun 2016 00:12:31 +0000 (20:12 -0400)]
Final excision of libgsystem dependency

Lots and lots of preparation led to this moment - when nothing
apparent changes for users!  Woo!

But seriously, having the extra dependency is a minor annoyance, and
in the big picture I think the libgsystem idea was wrong - we need to
land things in GLib, and use git submodules for API-unstable or
Linux-specific sharing.  For a lot of OSTree, the libgsystem `GFile*`
orientation was also wrong, we really want fd-relative.

Closes: #444
Approved by: jlebon

9 years agoprune: Retain the tip of each ref even with date pruning
Colin Walters [Mon, 8 Aug 2016 19:41:09 +0000 (15:41 -0400)]
prune: Retain the tip of each ref even with date pruning

I hit an error with [CAHC](https://wiki.centos.org/SpecialInterestGroup/Atomic/Devel)
where we were doing time-based pruning.  `ostree summary -u` started failing,
and it took me a bit to realize it was because we were pruning
even the tip of old branches, which I was not at all expecting,
and I don't think users will too.

Perhaps in the future we could add some sort of --prune-ref-tips or
something if people wanted it, but I doubt it.

Closes: #445
Approved by: jlebon

9 years agobuild: Update .gitignore
Colin Walters [Tue, 9 Aug 2016 00:19:54 +0000 (20:19 -0400)]
build: Update .gitignore

The patch to add more symlink bits also needed CLEANFILES updates.

Closes: #446
Approved by: jlebon

9 years agodeploy: Use internal recursive copy rather than libgsystem
Colin Walters [Thu, 4 Aug 2016 13:37:26 +0000 (09:37 -0400)]
deploy: Use internal recursive copy rather than libgsystem

Since we already had a "recursive copy" implementation here, let's
reuse it rather than the libgsystem `gs_shutil_cp_a()`.  Part of the
libglnx porting.

Closes: #428
Approved by: jlebon

9 years agodeploy: Port file copying code to GLnxDirFdIterator
Colin Walters [Thu, 4 Aug 2016 01:24:09 +0000 (21:24 -0400)]
deploy: Port file copying code to GLnxDirFdIterator

It handles ownership of the `DIR*` for us more cleanly, and
is just a better API.

This is in preparation for further changes to this code to do SELinux
labeling while copying.

Closes: #428
Approved by: jlebon

9 years agorepo: Fix an uninitialized variable
Colin Walters [Mon, 8 Aug 2016 10:34:50 +0000 (06:34 -0400)]
repo: Fix an uninitialized variable

Closes: #431
Approved by: giuseppe

9 years agobuild: Make -Werror=int-conversion fatal
Colin Walters [Thu, 4 Aug 2016 20:58:07 +0000 (16:58 -0400)]
build: Make -Werror=int-conversion fatal

This should hopefully avoid me accidentally passing NULL for an `int`
file descriptor in the future.

Closes: #431
Approved by: giuseppe

9 years agobuild: Import attributes.m4, detect CFLAGS at build time
Colin Walters [Thu, 4 Aug 2016 20:47:46 +0000 (16:47 -0400)]
build: Import attributes.m4, detect CFLAGS at build time

I want to add `-Werror=int-conversion`, but it's only available in
newer GCC versions.  So let's start autodetecting available compiler
flags.

Closes: #431
Approved by: giuseppe

9 years agorepo: Drop more internally unused GFile members
Colin Walters [Fri, 5 Aug 2016 11:08:14 +0000 (07:08 -0400)]
repo: Drop more internally unused GFile members

I forgot to actually remove `config_file` in the previous
commit, the txn lock hasn't been used in a long time, and
for the uncompressed cache, everything uses the fd already.

Closes: #433
Approved by: giuseppe

9 years agotravis: run the test suite on various distributions
Simon McVittie [Fri, 5 Aug 2016 21:12:55 +0000 (22:12 +0100)]
travis: run the test suite on various distributions

.travis.yml is obviously still Travis-specific, but tests/ci-* are
designed to be shareable with other CI environments if there is interest
in doing so.

At the moment I'm only testing on Debian and Ubuntu. In principle we
could try a non-Debian-derived Docker container such as Fedora or CentOS
inside travis-ci's Ubuntu environment, similar to what I'm doing
for Debian, but I don't know the correct setup commands to use there.

Closes: #438
Approved by: cgwalters

9 years ago.travis.yml: Delete, we aren't using it right now
Colin Walters [Fri, 5 Aug 2016 20:30:13 +0000 (16:30 -0400)]
.travis.yml: Delete, we aren't using it right now

@smcv will re-add a new version.

Closes: #439
Approved by: smcv

9 years agoSkip tests that use whiteouts under Docker/aufs
Simon McVittie [Fri, 5 Aug 2016 19:41:05 +0000 (20:41 +0100)]
Skip tests that use whiteouts under Docker/aufs

ostree's naming convention for whiteouts is similar to what is
done in aufs, which means we can't compose the trees to test this
feature under Docker with the aufs storage driver, as used on
travis-ci.

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #437
Approved by: cgwalters

9 years agoUpdate libglnx: Add missing files to libglnx distribution
Simon McVittie [Fri, 5 Aug 2016 13:38:34 +0000 (14:38 +0100)]
Update libglnx: Add missing files to libglnx distribution

This fixes distcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #436
Approved by: cgwalters

9 years agorepo: Drop internal GFile config_file
Colin Walters [Fri, 5 Aug 2016 01:49:05 +0000 (21:49 -0400)]
repo: Drop internal GFile config_file

The remote parsing code still uses GFiles but this is a start.

Closes: #432
Approved by: giuseppe